<template>
  <div class="about">
    <h1>This is an about page</h1>
    <button @click="dianji">点击下载</button>
  </div>
</template>

<script lang="ts">
/** 测试方法数据 */
import {
  dataList,
  testArr1,
  testArr2,
  testArrObj1,
  testArrObj2,
} from "./AboutViewApi";

/** 测试方法 */
import {
  getPromises,
  getNode,
  getParentIdAll,
  arrAndSet,
  arrIntersection,
  arrDifference,
} from "./test-api/method-collection";

import { isString } from "./test-api/regular";
import { downLoadFile, fileUrlType, Base64Blob, urlToFile, urlToBlob } from "./test-api/file";
import { defineComponent } from 'vue'
/** 禁用操作 */
import { DisableConsole, enableConsole } from "./test-api/prohibit";
// import { saveAs } from 'file-saver';
import { arrayObjMatching } from "./test-api/typeJudgment";

export default defineComponent({
  data() {
    return {
      files: `https://168test.oss-cn-hangzhou.aliyuncs.com/graduateFile/72c94433-9431-4a22-a296-97db447313ba.docx`,
      file1: "https://168wangxiao.oss-cn-beijing.aliyuncs.com/thesis/template/03975737241bc5f56c91e431e219c418.xlsx",
      base64: ""
    }
  },
  created() {
    // DisableConsole(true)
    // enableConsole()
    // this.Base64Img()
    // const base64 = `https://cexatu.168wangxiao.com/sch/static/img/500.5492b5.png`

    // getPromises(base64).then(res => {
    //   console.log(res);
    // })
    // console.log("isString方法", isString());
    // console.log("arrAndSet方法222", arrAndSet(testArrObj2, testArrObj1));
    // console.log("getNode方法", getNode(dataList, 'children', 'label', "一级1"))
    // console.log("getParentIdAll方法", getParentIdAll(dataList, 'id', 10 ,'children'))

    // console.log("arrAndSet", arrAndSet(testArr1, testArr2));
    // console.log("arrIntersection", arrIntersection(testArr1, testArr2));
    // console.log("arrDifference", arrDifference(testArr1, testArr2));
    // console.log('fileUrlType', fileUrlType(this.files, true));
    // console.log('fileUrlType', fileUrlType(this.file1, false));
    
    // const fileUrl = "https://168test.oss-cn-hangzhou.aliyuncs.com/graduateFile/d13db22f-15fc-4ec9-904c-27685e768942.jpeg"
    // console.log('fileUrlType', fileUrlType(fileUrl, true));
    

    console.log(Base64Blob(this.base64, null));
    function blobToUrl(blob: Blob | null) {
      if(blob){
        return URL.createObjectURL(blob);
      }
    }

    const blob = new Blob(['Blob内容'], { type: 'text/plain' });
    const blobUrl = blobToUrl(Base64Blob(this.base64, null));
    console.log(blobUrl, "Blob");

    const url = "https://168wangxiao.oss-cn-beijing.aliyuncs.com/thesis/template/2e200739b4cc52a9f228bc1d69c3ff6f.pdf"
    const nameFile = "文件下载.pdf"
    urlToFile(url, nameFile).then((file) => {
      if (file) {
        console.log(file, "文件下载")
        console.log(URL.createObjectURL(file), "file");

      } else {
        console.log(file, "下载失败！")
      }
    })

    // urlToBlob(url, "").then((r: any) => {
    //   console.log(r, "UDUDUDUDUDU^^#^#^%#%#%#")
    // })
  },
  methods: {
    dianji(): void {
      downLoadFile(this.files, "下载文件", true);
    },
    // Base64Img(){
    //   convertAndRender(this.base64, "5555555").then(res => saveAs(res, "hhhhhhhh.zip"))
    // }
  }
});
</script>
